Spawning System
This system allow you to spawn every thing you need (ennemies, objects, etc...) using several rules. __FORCETOC__ Create a Spawner To create a spawner, you can use any kind of object. Generally it will be an invisible object. Now you must define all initialization variables of the spawner system in a "once" statement: 1) Define simple variables: *destroyWhenSpawnedCount (number) : if the remaining number (not destroyed) of spawend items less or equals to this value, this spawner object will be destroyed. **If you do not want your spawner object can be destroyed, set "-1" to *refillWhenSpawnedCountLesserThan (number) '': if the remaining number (not destroyed) of spawend items '''less '''to this value, the spawning system will respawn items to its maximum capacity. **This behavior is prioritary to '''destroyWhenSpawnedCount ' *durationBeforeRefill (number) : the number of second to wait before refilling since the condition to refill occurs. *spawnCapacity (number) '': the total number of items spawned after a refill or at initial spawning *spawnRadius ''(number) : for item that not need to be spawned at a given location. This number provide the radius used to compute a random location around this spawner object. *isAtRandom (boolean) : true, if you want to spawn an item randomly from the collection of spawnable items. **false, to cycle around all spawnable items (in this case, i recommand to use a MAX_CAPACITY who is a multiple of the spawnable items count. 2) Then you must define the list of spawnable items (only "template" are supported) *store the template in an object variable (i.e. ) *define some variable on this object. Here all supported variable: **isSingleton (boolean) : true if only one single instance must exists at a time (as it is based on the "name" of the object, be sure to choose a unique name - for scope of this spawned) **spawnAtMyLoc (boolean) : true if this item will be spawned at a given location (specified via the <''spawnLoc> ''variable), false if it will be spawned randomly around the spawner. **''spawnLoc (vector)'' : world position to spawn this item. **spawnProbability (number) : percentage of chance to be spawned (the sum of all spawnable item proabilities must be equals to 100) *finally add it to the collection variable 3) Finally you must add the "Spawning System" brain template in a channel named "spawingSystemChannel" This system is powerfull because a spawnable item can be spawner, and as you have many variables to configure the system, i hope you will be able to achieve all your needs. Usefull spawner variable Here a list of inner variable that you can use (get/set) to enhance the spawner behavior: *countItemSpawned (number) : each time an item is spawned, this counter is incremented by 1 *spawnedItems (collection) : contains all existing (not destroyed) spawned item. *spawnDepleted (boolean) : true is the spawn have been depleted (all spawned item have been destroyed). Works only if you does not tell the spawner to refill automatically (refillWhenSpawnedCountLesserThan = 0) *forceSpawnRefill'' (boolean)'' : true if you want to force the spawner to refill immediatly Here some ideas to customize the spawner and create your own behavior: *have 3 waves, 1st: 5 mobs, 2nd: 3 mobs, 3rd: boss **Initialize the spawner for the 1st wave, and be sure to have: ***refillWhenSpawnedCountLesserThan = 0 ***destroyWhenSpawnedCount = -1 ***switch to a new page (2) **(2) The page waiting the spawn have been depleted to create the second wave : ***WHEN DO ****Clear the spawnable collection and add your template(s) for the second wave ****set = false ****set = true ****switch to a new page (3) **(3) The page waiting the spawn have been depleted to create the 2nd wave : ***WHEN DO ****Clear the spawnable collection and add your template(s) for the 3rd wave ****set = false ****set = true ****set = 0 if you want the spawner will be destroyed after spawning the last wave ****switch to a new page (4 - empty page) Advanced Spawning Example Here an example to illustrate the capabilities of the spawning system (Recursive spawn) *Spawning System brain is a template *(1) and (placeholder) are not '''templates. *(a), (b), ©, (d) and (2) are templates. '''Main Spawner: The goal is to create a spawner (1) following the following rules: - Spawn 5 objects. Each object can be a goblin (a)/(b) or a treasure place (2) - Object are spawned randomly with different kind of probabilities *(a) 47%, (b) 47%, (2) 6% *(2) is a singleton, so it is imposible to have several copy at a time. - The position of the created element depend of this type *(a)/(b) in a random position around (1), in a maximum range of 11 *(2) is spawned at the (placeholder) location - (1) refill the crater (respawn 5 elements), 5 seconde after the previous 5 element have been destroyed *(a)/(b)/©/(d) are destroyed when killed by player *The Goblin treasure chest (2) is destroyed when openned. This image contains "MAX_CAPACITY" instead of "spawnCapacity" -------> Secondary Spawner When (2) is spawned by the main spawner, it will create 4 elements (not random) *(d) one time as it is a singleton *© 3 times - The position of the created element is around (2), in a maximum range of 2. This image contains "MAX_CAPACITY" instead of "spawnCapacity" -------> ''Loot system'' This system can be used as a loot system, this mean that spawned item are directly created inside the spawner object inventory. For exemple a chest or a dead body. *If you want that all spawned items are stored inside the inventory of the spawner object, simply add set the boolean "spawnAsLoot" to "true". *If you want that only specific spawned items are stored inside the inventory of the spawner object, simply add set the boolean "spawnAsLoot" to "true" to the template initialization part of the spawner (where we define the "temp" variable) If you want to loot a stackable item, you must initialize the template ("temp" section) to specify: *stacksize *STACK_SIZE_MAX *isStackable